/**
 * 富文本
 */
layui.define(['jquery','dialogUtil','layedit','layer'],function(exports){
    var $ = layui.jquery;
    var layedit = layui.layedit,
        dialogUtil = layui.dialogUtil;
    var layer = parent.layer === undefined ? layui.layer : top.layer;
    var richTxtUtil = {
        /**
         * KnifeZ文本编辑器
         *
         * @param objId 对象Id
         * @param height 高度
         * @author shengQiang yu
         * @date 2019-04-11 9:28
         */
        layeditKnifezBuild: function (objId, height) {
        if (height == null || height == "") {
            height = 400;
        }
        layedit.set({
            uploadImage: {
                url: '/sysFile/layEditUpload',
                data: {catalog: "/sys/layedit"}, //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
                type: 'post', //默认post
                accept: 'image',
                acceptMime: 'image/*',
                exts: 'jpg|png|gif|bmp|jpeg',
                size: 1024 * 10,
                done: function (data) {
                    console.log(data);
                }
            }
            , uploadVideo: {
                url: '/sysFile/layEditUpload',
                data: {catalog: "/sys/layedit"}, //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
                type: 'post', //默认post
                accept: 'video',
                acceptMime: 'video/*',
                exts: 'mp4|flv|avi|rm|rmvb',
                size: 1024 * 10 * 2,
                done: function (data) {
                    console.log(data);
                }
            }
            , uploadFiles: {
                url: '/sysFile/layEditUpload',
                data: {catalog: "/sys/layedit"}, //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
                type: 'post', //默认post
                accept: 'file',
                acceptMime: 'file/*',
                size: '20480',
                done: function (data) {
                    console.log(data);
                }
            }
            , devmode: true
            , codeConfig: {
                hide: false,  //是否显示编码语言选择框
                default: 'javascript' //hide为true时的默认语言格式
            }
            , videoAttr: ' preload="none" '
            , tool: [
                'html', 'undo', 'redo', 'code', 'strong', 'italic', 'underline', 'del', 'addhr', '|', 'fontFomatt', 'fontfamily','fontSize', 'fontBackColor', 'colorpicker', 'face'
                , '|', 'left', 'center', 'right', '|', 'link', 'unlink', 'images', 'image_alt', 'video','attachment', '|'
                , 'table', 'fullScreen'
            ]
            , height: height+'px'
        });
        var index = layedit.build(objId);
        return index;
    }/**
         * 简单文本编辑器
         *
         * @param objId 对象Id
         * @param height 高度
         * @author shengQiang yu
         * @date 2019-04-11 9:28
         */
        , layeditBuild: function (objId, height) {
            if (height == null || height == "") {
                height = 400;
            }
            layedit.set({
                uploadImage: {
                    url: '/sysFile/layEditUpload' //接口url
                    , data: {catalog: "/sys/layedit"} //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
                    , type: 'post' //默认post
                }
            });
            var index = layedit.build(objId, {
                tool: ['strong' //加粗
                    , 'italic' //斜体
                    , 'underline' //下划线
                    , 'del' //删除线
                    , '|' //分割线
                    , 'left' //左对齐
                    , 'center' //居中对齐
                    , 'right' //右对齐
                    , 'link' //超链接
                    , 'unlink' //清除链接
                    , 'image' //插入图片
                ],
                height: height+"px"
            });
            return index;
        },
        /**
         * 获取简单文本编辑器内容
         *
         * @param index 编辑器对象
         * @return
         * @author shengQiang yu
         * @date 2019-04-11 9:30
         */
        layeditBuildContent: function (index) {
            return layedit.getContent(index);
        }

    };

    exports('richTxtUtil', richTxtUtil);


});
